<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        const p = new Promise((resolve, reject) => {
            const age = 0;
            if (age >= 1 && age <= 100) {
                resolve();
            } else {
                reject(new Error('age is error'));
                // throw new Error('age is error');
            }
        })
        p.then(() => {
            console.log('right');
        }).catch((err) => {
            console.log(err.message);
        });
    </script>
</body>

</html>